package com.发布订阅模式;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2023/8/9 14:01
 * @description:
 * @version:
 */
public class Main {
    public static void main(String[] args) {
        MessageBroker messageBroker = new MessageBroker();
        Subscriber subscriber = new EmailSubscriber("1835734390@qq.com");
        Subscriber subscriber2 = new EmailSubscriber("1111111111111@qq.com");
        messageBroker.subscribe("news", subscriber);
        messageBroker.subscribe("food",subscriber2);
        messageBroker.publish("news", "Breaking News!"); // 发布消息
        messageBroker.publish("food","盒饭到了");
    }
}
